/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package com.stip.server.tools;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;

/**
 *
 * @author BlueBerry
 */
 public  class MD5Tools {
   public static  String MD5Process(String code) throws NoSuchAlgorithmException{
    MessageDigest md=MessageDigest.getInstance("MD5");
    byte[] aBytes= md.digest(code.getBytes());
    StringBuffer   buff   =   new   StringBuffer(); 
    for(int   i   =   0;   i   <   aBytes.length;   i++)   { 
    String   byteStr   =   Integer.toHexString(aBytes[i]   &   0xFF); 
    if(byteStr.length()   <   2) 
        buff.append('0'); 
    buff.append(byteStr); 
}
    return  new String(buff);
   } 
   public  String tokenMD5(String password) throws NoSuchAlgorithmException{
   
   return   MD5Process(MD5Process(password+new Date().toString()));
   
   }
}
